<template>
	<view>
		<view class="uni-common-mt">
			<!-- <form @submit="formSubmit"></form> -->
			<view class="uni-form-item uni-column">
				<view class="title">用户名</view>
				<input class="uni-input" v-model="account" focus placeholder="请输入用户名" />
			</view>
			<view class="uni-form-item uni-column">
				<view class="title">密码</view>
				<input class="uni-input" v-model="password" password type="text" placeholder="请输入密码" />
			</view>
			<button type="primary" :loading="loginLoading" @click="login">登 录</button>
			<button type="primary" @click="wechatlogin">微信登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginLoading: false,
				account: "",
				password: ""
			}
		},
		methods: {
			login () {
				// this.loginLoading = true
				// this.$api.login(this.account, this.password).then(
				// 	(res) => {
				// 		console.log("s",res)
				// 		this.$api.setToken(res.result.token)
				// 	}
				// ).catch(
				// 	(res) => {
				// 		console.log("r",res)
				// 	}
				// ).finally(() => {
				// 	console.log("complete")
				// 	this.loginLoading = false
				// })
				uni.navigateTo({
					url:"../index/index",
					success() {
						console.log("success")
					},
					fail() {
						console.log("fail")
					},
					complete() {
						console.log("complete")
					}
				})
			},
			wechatlogin() {
				uni.login({
				  provider: 'weixin',
				  success: function (loginRes) {
				    console.log(loginRes.authResult);
				    // 获取用户信息
				    uni.getUserInfo({
				      provider: 'weixin',
				      success: function (infoRes) {
				        console.log('用户昵称为：' + infoRes.userInfo.nickName);
				      }
				    });
				  }
				});
			}
		}
	}
</script>

<style lang="scss">

</style>
